<?php
if (file_exists('config.xml')) {
    $xml = simplexml_load_file('config.xml');
	foreach ($xml->galserver->children() as $child => $valor)
	{
		switch($child)
			{
				case "url": $url=$valor;
							break;
				case "usuario": $usu_server=$valor;
							break;
				case "senha": $pwd_server=$valor;
							break;
		}								
	}
	foreach ($xml->galbd->children() as $child => $valor)   
	{
		switch($child)
			{
				case "servidor": $servidor_bd=$valor;
							break;
				case "bancodados": $nome_bd=$valor;
							break;
				case "usuario": $usu_bd=$valor;
							break;
				case "senha": $pwd_bd=$valor;
							break;
							
		}						
	}
		foreach ($xml->interfacebd->children() as $child => $valor)   
	{
		switch($child)
			{
				case "servidor": $servidor_bdi=$valor;
							break;
				case "bancodados": $nome_bdi=$valor;
							break;
				case "usuario": $usu_bdi=$valor;
							break;
				case "senha": $pwd_bdi=$valor;
							break;
							
		}						
	}
} else {

$url="http://";
$usu_server="servidor";
$pwd_server="senha1";
$servidor_bd="server bd";
$nome_bd="nome bd";
$usu_bd="usuario bd";
$pwd_bd="senha bd";
$servidor_bdi="nome bd interface";
$nome_bdi="nome bd interface";
$usu_bdi="usuario bd interface" ;
$pwd_bdi="senha BD interface";
}

?>
<script src="funcoes.js" language="javascript"></script>
<style type="text/css">

fieldset
{
width:650px;
}

legend
{
color:#0066FF;
font-family:verdana,arial;
font-size: 18px;
}
label{
width:520px;
padding:10px;
color:#0066FF;
float:left;
}
.c2{
width:270px;
padding:10px;
color:#0066FF;
float:left;
z-index:2;
}
span
{
position:relative;
top:2px;
right:0px;
text-align: left;
z-index:1;
}
</style>


<form action="funcoes.php" name="frm_conf" id="frm_conf" method="post" enctype="application/x-www-form-urlencoded">
<input type="hidden" id="action" name="action" />
<fieldset>
<legend>Servidor - GAL</legend>
<label><span>URL completa:</span><input type="text" name="url" id="url" size="60" value="<?php echo $url; ?>" readonly="true"></label>
<label class="c2"><span>Usuario:</span><input type="text" name="usergal" id="usergal" value="<?php echo $usu_server; ?>" readonly="true"></label>
<label class="c2"><span>Senha:</span><input type="password" name="pwdgal" id="pwdgal" value="<?php echo $pwd_server; ?>" readonly="true"></label>
</fieldset>
<fieldset>
<legend>Banco de Dados - GAL</legend>
<label  class="c2"><span>Servidor:</span><input type="text" name="serverbd" id="serverbd" value="<?php echo $servidor_bd; ?>" readonly="true"></label>
<label  class="c2"><span>Banco de Dados:</span><input type="text" name="namebd" id="namebd" value="<?php echo $nome_bd; ?>" readonly="true"></label>
<label class="c2"><span>Usuario:</span><input type="text" name="userbd" id="userbd" value="<?php echo $usu_bd; ?>" readonly="true"></label>
<label class="c2"><span>Senha:</span><input type="password" name="pwdbd" id="pwdbd" value="<?php echo $pwd_bd; ?>" readonly="true"></label>
</fieldset>
<fieldset>
<legend>Banco de Dados - Interface</legend>
<label  class="c2"><span>Servidor:</span><input type="text" name="serverbdi" id="serverbdi" value="<?php echo $servidor_bdi; ?>" readonly="true"></label>
<label  class="c2"><span>Banco de Dados:</span><input type="text" name="namebdi" id="namebdi" value="<?php echo $nome_bdi; ?>" readonly="true"></label>
<label class="c2"><span>Usuario:</span><input type="text" name="userbdi" id="userbdi" value="<?php echo $usu_bdi; ?>" readonly="true"></label>
<label class="c2"><span>Senha:</span><input type="password" name="pwdbdi" id="pwdbdi" value="<?php echo $pwd_bdi; ?>" readonly="true"></label>
</fieldset>
<br>
<input id="beditar" type="button" value="Editar" class="botao" onclick="javascript:editar();" />  
<input id="salvar" disabled="disabled" type="button" value="Salvar" class="botao" onclick="javascript:doPost('frm_conf', 'salvar');" />   
<input id="testar" type="reset" value="Testar" class="botao" onclick="javascript:testa_conexao();" />    
</form>

